<template>

  <div>

    <!--结账、并牌输入框-->
    <el-form ref="form" :model="form" label-width="100px">
      <div style="display: flex">
        <div style="flex: 1">

          <el-form-item label="结账手牌：">
            <el-input placeholder="请输入结账手牌" v-model="form.numjie"/>
          </el-form-item>
          <el-form-item label="并牌手牌：">
            <el-input placeholder="请输入并牌手牌" v-model="form.numbing"/>
          </el-form-item>

        </div>
      </div>
    </el-form>

    <!--读牌-->
    <div class="anniu">
      <el-button type="primary" class="dupn" @click.native.stop.prevent="bing">
        并 牌
      </el-button>
      <el-button class="dupn" @click.native.stop.prevent="close">返 回</el-button>
    </div>


  </div>
</template>

<script>
import {check, bingpai} from "@/api/module/ljw/bingpai"

export default {
  data() {
    name: "bingpai"
    return {
      form: {
        numjie: '',
        numbing: '',
      },

      // 查询参数
      queryParams: {
        userId: null,
        deptId: null,
        department: null,
        nickName: null,
        userName: null,
        post: null,
        handBrand: null,
        handCategory: null,
        handState: null,
        retentionStatus: null,
        mergeStatus: null,
        openingTime: null,
        drawTime: null,
        mergeHands: null,
        mergeBarBillsId: null,
        leaveTime: null,
        beforeLeave: null,
        beforeBarBillsId: null,
        entryName: null,
        projectCategory: null,
        projectCode: null,
        mnemonicCode: null,
        unit: null,
        unitPrice: null,
        commissionPrice: null,
        together: null,
        sailingsSigns: null,
        barBillsId: null,
        recordingTime: null,
        quantity: null,
        totalAmount: null,
        seat: null,
        orderNumber: null,
        paymentMethod: null,
        consumptionStatus: null,
        chargebackTime: null,
        reasonForChargeback: null,
        chargebackProcessorAccount: null,
        chargebackProcessorName: null,
        clockTime: null,
        nextClockTime: null,
        nextClockStatus: null,
        recordEmployeeNumber: null,
        recorderEmployeeName: null,
        roomType: null,
        openingHours: null,
        checkOutTime: null,
        checkOutStatus: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      },
    }
  },
  methods: {

    // 表单重置
    reset() {
      this.form={
        numjie: '',
        numbing: ''
      }
      this.resetForm("form");
    },

    // 取消
    close(){
      this.$emit("closeDialog")
      this.reset()
    },

    bing() {
      // console.log(this.form.numjie)
      // console.log(this.form.numbing)

      const numbing = this.form.numbing
      const numjie = this.form.numjie

      if(numbing.includes(' ')){
        this.$modal.msgError("并牌手牌不能含有空格")
      }
      else if(numjie.includes(' ')){
        this.$modal.msgError("结账手牌不能含有空格")
      }
      else if(numbing === ""){
        this.$modal.msgError("并牌手牌不能为空")
      }
      else if(numjie === ""){
        this.$modal.msgError("结账手牌不能为空")
      }

      if (numbing !== "" && numjie !== "" && !numbing.includes(' ') && !numjie.includes(' ')) {
        this.queryParams.handBrand = numbing
        this.queryParams.mergeHands = numjie
        check(this.queryParams).then(res => {
          // this.$modal.msgSuccess("并牌成功");
          if (res === "") {
            bingpai(this.queryParams).then(response => {
              this.$modal.msgSuccess("并牌成功");
            })
            // console.log("成功")
          } else {
            this.$modal.confirm(res).then(function () {
            }).then(() => {
              bingpai(this.queryParams).then(response => {
                this.$modal.msgSuccess("并牌成功");
              }).catch(() => {
              })
            })
            // console.log(res)
          }
        })
      }
      // this.reset();
    },
  }
}
</script>

<style lang="scss" scoped>

.anniu {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.dupn {
  position: relative;
}


</style>
